<?php

App::uses('Controller', 'Controller');
App::uses('EasyDate', 'Lib/Utility');

class EasyDateTest extends CakeTestCase {
	public $EasyDate = null;

	public function setUp() {
		parent::setUp();
		$this->EasyDate = new EasyDate();
	}

	public function testDates(){
		$this->EasyDate->onErrorReturnCurrentDate = false;
		$actual = $this->EasyDate->change(5);
		$expected = date('Y-m-') . '05';
		$this->assertEquals($expected, $actual);

		$actual = $this->EasyDate->change('1-2');
		$expected = date('Y-') . '01-02';
		$this->assertEquals($expected, $actual);

		$actual = $this->EasyDate->change('5-5-5');
		$expected = '2005-05-05';
		$this->assertEquals($expected, $actual);		
		
		$this->EasyDate->onErrorReturnCurrentDate = true;
		$actual = $this->EasyDate->change();
		$expected = date('Y-m-d');
		$this->assertEquals($expected, $actual);

	}
	
	public function testErrorz(){
		$this->EasyDate->onErrorReturnCurrentDate = false;
		$actual = $this->EasyDate->change();
		$expected = false;
		$this->assertEquals($expected, $actual);

		$actual = $this->EasyDate->change('8-27 and some extra string');
		$expected = false;
		$this->assertEquals($expected, $actual);

		$actual = $this->EasyDate->change('some string');
		$expected = false;
		$this->assertEquals($expected, $actual);

		$this->EasyDate->onErrorReturnCurrentDate = true;
		$actual = $this->EasyDate->change('some string');
		$expected = date('Y-m-d');
		$this->assertEquals($expected, $actual);
	}
}
?>